﻿using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using GraphSharp.Controls;
using XmlStudio.Helper;

namespace XmlStudio.Dialogs {
    /// <summary>
    /// Interaction logic for ChangeAppearanceDialog.xaml
    /// </summary>
    // ReSharper disable RedundantExtendsListEntry
    public partial class ChangeAppearanceDialog : Window {
        // ReSharper restore RedundantExtendsListEntry

        public string SelectedAppearance { get; private set; }

        public ChangeAppearanceDialog() {
            InitializeComponent();
        }

        private void OKClicked(object sender, RoutedEventArgs e) {
            if(border_Appearances.Child is ComboBox) {
                var cb = border_Appearances.Child as ComboBox;
                var selectedItem = cb.SelectedItem;
                if(selectedItem is ComboBoxItem) {
                    var selectedComboBoxItem = selectedItem as ComboBoxItem;
                    var appearance = selectedComboBoxItem.Tag as String;
                    if(appearance != null) {
                        this.SelectedAppearance = appearance;
                        this.DialogResult = true;
                        //var template = Application.Current.TryFindResource(appearance) as ControlTemplate;
                        //var selectedItems = SelectionService.Instance.CurrentSelection.Cast<VertexControl>();
                        //if(selectedItems.Count() > 0 && template != null) {
                        //    foreach(var item in selectedItems) {
                        //        item.AppearanceTemplate = template;
                        //    }
                        //}
                    }
                }
            }

            this.Close();
        }
    }
}